/**
 * ReportGear(2011)
 */
package com.reportgear.report.model.cell.value.salary;

import org.dom4j.Element;

import com.reportgear.report.model.cell.value.AbstractCellObject;
import com.reportgear.report.model.cell.value.ModelDesignableValueObjectClassManager;

/**
 * 工资公式对象
 * 
 * @version 1.0 2011-4-4
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public class SalaryFormulaObject extends AbstractCellObject {
	/**
	 * 公式
	 */
	private String formula = "";
	/**
	 * 描述
	 */
	private String caption = "";

	@Override
	public String toString() {
		return this.getCaption();
	}

	public void setCaption(String caption) {
		this.caption = caption;
	}

	public String getCaption() {
		return caption;
	}

	public void setFormula(String formula) {
		this.formula = formula;
	}

	public String getFormula() {
		return formula;
	}

	@Override
	public void read(Element parent) {
		this.setFormula(parent.elementTextTrim("formulaStr"));
		this.setCaption(parent.elementTextTrim("caption"));
	}

	@Override
	public void write(Element parent) {
		parent.addAttribute("class", ModelDesignableValueObjectClassManager.INSTANCE.getClassKey(this.getClass()));

		Element el = parent.addElement("formulaStr");
		el.addText(this.formula);

		el = parent.addElement("caption");
		el.addText(this.caption);
	}
}
